package com.yaoli.ajob;

import java.util.Comparator;
import java.util.PriorityQueue;

import static com.yaoli.ajob.ClimbingStairs.count;

/**
 * Created by siemens on 4/17/2017.
 */
public class _215_KthLargestElementinanArray {


    public int findKthLargest(int[] nums, int k) {
        Comparator<Integer> comp = new Comparator<Integer>(){
            public int compare(Integer a,Integer b){
                return b - a;
            }
        };

        PriorityQueue<Integer> queue = new PriorityQueue<Integer>(comp);

        for(int i = 0 ; i< nums.length ; i++){
            queue.offer(nums[i]);
        }

        int res =0;

        for(int i = 0 ; i < k ; i++){
            res = queue.poll();
        }

        return res;
    }
}
